package com.battery.controller;

import com.battery.pojo.Sys_menu;
import com.battery.service.Sys_menuService;
import com.battery.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "系统菜单管理相关接口")
public class Sys_menuController {
    @Autowired
    Sys_menuService sys_menuService;

    @PostMapping("/sys_menu")
    @ResponseBody
    @ApiOperation("列出所有系统菜单")
    public Result showSys_menu(){

        Result result = sys_menuService.queryAllSys_menu();
        return Result.ok().data("data",result);

    }

    @PostMapping(value = "/addsys_menu")
    @ResponseBody
    @ApiOperation("添加系统菜单")
    public Result addSys_menu(@RequestBody @ApiParam(name="系统菜单对象",value="传入json格式",required=true)Sys_menu sys_menu){

        System.out.println(sys_menu.getMenu_id());
        return sys_menuService.addSys_menu(sys_menu);

    }

    @DeleteMapping("/deletesys_menu/{menu_id}")
    @ResponseBody
    @ApiOperation("删除系统菜单")
    public Result deleteSys_menu(@PathVariable("menu_id") @ApiParam(name="系统菜单id",required=true) String menu_id){

        return sys_menuService.dropSys_menu(menu_id);

    }

    @GetMapping("/querysys_menu/{menu_id}")
    @ResponseBody
    @ApiOperation("查找系统菜单")
    public Result querySys_menu(@PathVariable("menu_id") @ApiParam(name="系统菜单id",required=true) String menu_id){

        return sys_menuService.querySys_menuByID(menu_id);

    }

    @PutMapping("/modifysys_menu")
    @ResponseBody
    @ApiOperation("修改系统菜单")
    public Result modifySys_menu(@RequestBody @ApiParam(name="系统菜单对象",value="传入json格式",required=true) Sys_menu sys_menu){

        return sys_menuService.modifySys_menu(sys_menu);

    }
}
